package dataStructure.chapter03_链表.part4双向循环链表.JosephusProblem;

/**
 * @author https://gitee.com/W_Jun
 * @date 2022-02-17 21:39
 * @Description 约瑟夫问题
 */
public class TestJosephus {
    public static void main(String[] args) {
        josephus();
    }
    static void josephus() {
        CircleLinkedList<Integer> list = new CircleLinkedList<>();
        for (int i = 1; i < 9; i++) {
            list.add(i);
        }
        //指向头结点
        list.reset();
        while (!list.isEmpty()) {
            list.next();
            list.next();
            System.out.println(list.remove());
        }
    }
}
